//
//  ResponseData.swift
//  ECApp
//
//  Created by 程平 on 2017/10/21.
//

import Foundation
import PerfectLogger
class ResponseData {
    
   // static let standard = ResponseData()
    static let contentType = {
        return applicationJson + ";"+charset
    }()
    static let applicationJson = "application/json"
    static let charset = "charset=utf-8"
    private init() {
        
    }
    
   static func jsonData(resultCode:ResultCode, data: Any!) -> String {
        let resultData = (data == nil) ? "" :data
        let result = ["code":resultCode.rawValue,"message":resultCode.description,"data":resultData]
        
        guard let jsonString = try? result.jsonEncodedString() else {
            LogFile.error("返回结果数据格式化出错了")
            return ""
        }
        return jsonString
        
    }
}
